<?php

namespace Modules\Admin\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddAdminUserRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
//        第三个参数可以写数字，但是我们能写数字,一切以程序为主，不要以老师为主,获得参数的方法
        $id = $this->route('adminuser');

//        dd($id);

        return [
//            记住unique的四个参数
            'name'=>'required|unique:admins,name,'.$id,
            'nickname'=>'required|unique:admins,nickname,'.$id,
            'password'=>'nullable|between:6,20',
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
